class HomeController < ApplicationController

  caches_page :index
  
  layout "home"

  before_filter :get_nav_categories
  before_filter :get_regions

  def index
    @article_une = get_article_by_tags(['home_une'])[0]

    @articles_deux = get_article_by_tags(['home_deux'])
    if @articles_deux.size > 4
      @articles_deux = @articles_deux[0..3]
    end
    @page_title << " - Accueil"
  end  
  
  def contact
    return unless request.post?
    message = params[:message]
    send_email(message)
    flash[:notice] = "Votre message a été envoyé correctement."
    redirect_to home_url
  end
  
  def newsletter_signin
    #breakpoint
    return unless request.post?
    
    @message = Hash.new
    @message['email'] = params[:mail]
    @message['zonegeo'] = params[:zonegeo]
    Superman::deliver_inscription_newsletter(@message)
    Superman::deliver_confirmation_inscription_newsletter(@message)
    redirect_to article_url("confirmation-newsletter")
  end
  
  def search
    render :action => "search", :layout => "search"
  end
  
end
